package eyrolles;

import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletContext;

import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.action.ActionServlet;

public class EyrollesPlugin implements PlugIn {

  public static final String PROPERTIES = "PROPERTIES";
  private DBConnectionManager dBManager=null;
  private String filePath=null;
  
  public void init(ActionServlet servlet, ModuleConfig applicationConfig)
    throws javax.servlet.ServletException {

    System.out.println("---->Le plug-in demarre<----");
    ServletContext context=servlet.getServletContext();
    dBManager=DBConnectionManager.getInstance(getFilePath());
    context.setAttribute("DBManager", dBManager);
      
    }
    
 public String getFilePath () {
     return filePath;
 }
 public void setFilePath (String f){
     filePath=f;
 }

  public void destroy() {
   
    dBManager.release();
    System.out.println("---->Le plug-in s'arrete<----");
    
  }
}
